#ifndef WINDOW_STATUS_HPP_
#define WINDOW_STATUS_HPP_

#include <windows.h>

// bind an object to a numerical timestamp
template <class T>
struct Timestamp {
  Timestamp(T object, unsigned long long time)
  {
    m_object = object;
    m_time = time;
  }
  
  T m_object;
  unsigned long long m_time;
};

typedef int (CALLBACK * WINDOWSTATUSCALLBACK)(Timestamp<::HWND>* timestamp);

class WindowStatus
{
public:
  WindowStatus();
  ~WindowStatus();
  
  bool TogglePolling(bool state);
  bool IsRunning();
  
  void SetCallback(WINDOWSTATUSCALLBACK callback);
  WINDOWSTATUSCALLBACK GetCallback();
  
  static unsigned long PollWindows(void* param);
  
private:
  bool m_running;
  ::HANDLE m_thread;
  WINDOWSTATUSCALLBACK m_callback;

  // this decides the accuracy of our timestamps as this will
  // be the smallest increment our timestamps can make
  static const int POLLING_INTERVAL = 100;
};

#endif